package com.cal.utms.logAudit;

import java.math.BigInteger;
import java.sql.Connection;
import java.util.Date;

import org.hibernate.Session;

import com.cal.utms.action.user_maintenance.LoginAction;
import com.cal.utms.entity.AuidLog;
import com.cal.utms.util.HibernateUtil;

public class AuditLogUtil {

	public static void LogIt(String action, AuditLogInt entity, Connection conn) {

		Session tempSession = HibernateUtil.getSession().openSession(conn);
		int user = LoginAction.getCurrentLogingUser().getId();
		Date date = new Date();
		try {
			AuidLog auditRecord = new AuidLog(action, date, entity.getLogDeatil(), BigInteger.valueOf(entity.getLogId()), entity.getClass().toString(), user);
			tempSession.save(auditRecord);
			tempSession.flush();

		} finally {
			tempSession.close();

		}

	}
}
